unit datmd;

interface

uses
  SysUtils, Classes, DB, ADODB, clxs, IniFiles, Forms;

type
  Tdatmdfrm = class(TDataModule)
    Connect: TADOConnection;
    Worker: TADOTable;
    Group: TADOTable;
    Rcd: TADOTable;
    Punnet: TADOTable;
    CalcPayment: TADOQuery;
    General: TADOQuery;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private
    { Private declarations }
    procedure IniSystem;
  public
    { Public declarations }
  end;

var
  datmdfrm: Tdatmdfrm;

implementation

{$R *.dfm}

procedure Tdatmdfrm.IniSystem;
var
  IniFile:TIniFile;
  sEnable:String;
begin
  IniFile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'config');
  sEnable:=UpperCase(Trim(IniFile.ReadString('printer','IsLinePrinterEnable','Enable')));
  if sEnable='ENABLE' then IsLinePrinterEnable:=True else IsLinePrinterEnable:=False;

  sEnable:=UpperCase(Trim(IniFile.ReadString('printer','IsBackPrinterEnable','Enable')));
  if sEnable='ENABLE' then IsBackPrinterEnable:=True else IsBackPrinterEnable:=False;

  LinePrintName:=IniFile.ReadString('printer','LinePrintName','GP-5850II');
  LoginPort:= IniFile.ReadString('port','LoginPort','COM4');
  IssuePort:= IniFile.ReadString('port','IssuePort','COM5');

  CompanyName:= IniFile.ReadString('info','CompanyName','WinBlue Studio');
  SoftWareName:= IniFile.ReadString('info','SoftWareName','Packing-house-system');

  DatabaseSource:=IniFile.ReadString('database','dbsource',ExtractFilePath(Application.ExeName)+'\data\phs.mdb');
  DatabasePasswd:=IniFile.ReadString('database','dbpassword','harvest');

  connect.ConnectionString:=Format(DATA_CONNECT_STRING,[DatabaseSource,DatabasePasswd]);
end;

procedure Tdatmdfrm.DataModuleCreate(Sender: TObject);
begin
  IniSystem;
  //Connect.ConnectionString:=Format(DATA_CONNECT_STRING,[ApplicationPath+'Data\phs.mdb','harvest']);
  //Connect.Connected:=True;
end;

procedure Tdatmdfrm.DataModuleDestroy(Sender: TObject);
begin
  Connect.Connected:=False;
end;

end.
